package cn.yangliu.config.custom;

import java.io.Serializable;
import java.util.Objects;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

/**
 * 鉴权
 * @author 杨柳
 * @date 2019-06-01
 */
@Component
@Slf4j
public class PermissionEvaluator implements org.springframework.security.access.PermissionEvaluator {
    @Override
    public boolean hasPermission(Authentication authentication, Object target, Object permission) {
        //TODO 此处校验权限
        log.debug("check user's permission {}",permission);
        return Objects.equals(permission,"user:query2");
    }

    @Override
    public boolean hasPermission(Authentication authentication, Serializable serializable, String s, Object o) {
        return false;
    }
}
